﻿<phone:PhoneApplicationPage 
    x:Class="Coding4Fun.MissionControl.WP.Views.CommandsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Coding4Fun.MissionControl.WP.Converters"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False"
    xmlns:tkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    tkit:TiltEffect.IsTiltEnabled="True"
    DataContext="{Binding Path=Instance.CurrentServer,Source={StaticResource CommonViewModel}}">

    <phone:PhoneApplicationPage.Resources>
        <local:TemplateSelector x:Key="TemplateSelector"></local:TemplateSelector>
        <local:TypeToItemsPanel x:Key="TypeToItemsPanel"></local:TypeToItemsPanel>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.Background>
                <ImageBrush ImageSource="/Graphics/headlogo.png" Stretch="None"></ImageBrush>
            </Grid.Background>

            <StackPanel VerticalAlignment="Center">
                <TextBlock Text="AVAILABLE COMMANDS" Style="{StaticResource PhoneTextSubtleStyle}" HorizontalAlignment="Right"></TextBlock>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                </StackPanel>
            </StackPanel>
        </Grid>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,12,12,60">
            <ListBox ItemContainerStyle="{StaticResource ListBoxItemStyle}" x:Name="lstCommands" ItemsSource="{Binding Path=Instance.Commands,Source={StaticResource CommandsPageViewModel}}"
                     ItemTemplate="{Binding Instance.CurrentSetType, Converter={StaticResource TemplateSelector}, Source={StaticResource CommonViewModel}}"
                     SelectionChanged="lstCommands_SelectionChanged"
                     ItemsPanel="{Binding Instance.CurrentSetType, Converter={StaticResource TypeToItemsPanel}, Source={StaticResource CommonViewModel}}">
            </ListBox>
        </Grid>

        <Grid Grid.RowSpan="2" x:Name="grdConnectOverlay" LayoutUpdated="WaitingOverlayLayoutUpdated" Visibility="{Binding Path=Instance.IsWaiting,Source={StaticResource CommonViewModel},Converter={StaticResource BoolToVisibility}}">
            <Grid.Background>
                <SolidColorBrush Opacity=".6" Color="Black"></SolidColorBrush>
            </Grid.Background>

            <StackPanel VerticalAlignment="Center">
                <TextBlock HorizontalAlignment="Center" Margin="24" Text="Attempting to Connect..."></TextBlock>
                <ProgressBar VerticalAlignment="Center" x:Name="perfBar" IsIndeterminate="True"></ProgressBar>
            </StackPanel>
        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="False">
            <shell:ApplicationBarIconButton x:Name="btnLearn" Click="btnLearn_Click"  IconUri="/Graphics/appbar.add.png" Text="learn new"/>
            <shell:ApplicationBarIconButton x:Name="btnTrash" Click="btnTrash_Click" IconUri="/Graphics/appbar.delete.png" Text="remove set"/>
            <shell:ApplicationBarIconButton x:Name="btnRefresh" Click="btnRefresh_Click" IconUri="/Graphics/appbar.refresh.png" Text="refresh"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
